package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.domain.req.relation.ListDocumentRelationRequest;
import com.xy.biz.fd.domain.req.relation.SaveDocumentRelationRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.fd.domain.bo.DocumentRelationBO;
import com.xy.biz.fd.domain.po.DocumentRelationPO;
import com.xy.biz.fd.domain.query.DocumentRelationQuery;
import com.xy.biz.fd.domain.resp.GetDocumentRelationResponse;

/**
 *
 *
 * @author wcs
 * @date 2021-2-5
 */
public class DocumentRelationConverter {

	public static DocumentRelationPO toPO(DocumentRelationBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentRelationPO(), true);
	}

	public static List<DocumentRelationPO> toPO(Collection<DocumentRelationBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentRelationPO(), true);
	}

	public static DocumentRelationBO fromPO(DocumentRelationPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentRelationBO());
	}

	public static List<DocumentRelationBO> fromPO(Collection<DocumentRelationPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentRelationBO());
	}

	public static DocumentRelationBO toBO(SaveDocumentRelationRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentRelationBO(), true);
	}

	public static List<DocumentRelationBO> toBO(Collection<SaveDocumentRelationRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentRelationBO(), true);
	}

	public static List<DocumentRelationBO> toBOByPO(Collection<DocumentRelationPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentRelationBO(), true);
	}

	public static GetDocumentRelationResponse toResponse(DocumentRelationBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentRelationResponse());
	}

	public static List<GetDocumentRelationResponse> toResponse(Collection<DocumentRelationBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentRelationResponse());
	}

	public static DocumentRelationQuery toQuery(ListDocumentRelationRequest source) {
		if(null == source) {
			return null;
		}
		DocumentRelationQuery target = new DocumentRelationQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

	public static DocumentRelationQuery toQueryMax(ListDocumentRelationRequest source) {
		if(null == source) {
			return null;
		}
		DocumentRelationQuery target = DocumentRelationQuery.max().build();
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
